package com.ruoyi.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.domain.FacilitiesApplication;
import com.ruoyi.service.IFacilitiesApplicationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 设备申请Controller
 * 
 * @author ruoyi
 * @date 2025-01-11
 */
@RestController
@RequestMapping("/facilitiesApplication")
public class FacilitiesApplicationController extends BaseController
{
    @Autowired
    private IFacilitiesApplicationService facilitiesApplicationService;

    /**
     * 查询设备申请列表
     */
    @RequiresPermissions("fljg:facilitiesApplication:list")
    @GetMapping("/list")
    public TableDataInfo list(FacilitiesApplication facilitiesApplication)
    {
        startPage();
        List<FacilitiesApplication> list = facilitiesApplicationService.selectFacilitiesApplicationList(facilitiesApplication);
        return getDataTable(list);
    }

    /**
     * 导出设备申请列表
     */
    @RequiresPermissions("fljg:facilitiesApplication:export")
    @Log(title = "设备申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FacilitiesApplication facilitiesApplication)
    {
        List<FacilitiesApplication> list = facilitiesApplicationService.selectFacilitiesApplicationList(facilitiesApplication);
        ExcelUtil<FacilitiesApplication> util = new ExcelUtil<FacilitiesApplication>(FacilitiesApplication.class);
        util.exportExcel(response, list, "设备申请数据");
    }

    /**
     * 获取设备申请详细信息
     */
    @RequiresPermissions("fljg:facilitiesApplication:query")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(facilitiesApplicationService.selectFacilitiesApplicationByFid(fid));
    }

    /**
     * 新增设备申请
     */
    @RequiresPermissions("fljg:facilitiesApplication:add")
    @Log(title = "设备申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FacilitiesApplication facilitiesApplication)
    {
        return toAjax(facilitiesApplicationService.insertFacilitiesApplication(facilitiesApplication));
    }

    /**
     * 修改设备申请
     */
    @RequiresPermissions("fljg:facilitiesApplication:edit")
    @Log(title = "设备申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FacilitiesApplication facilitiesApplication)
    {
        return toAjax(facilitiesApplicationService.updateFacilitiesApplication(facilitiesApplication));
    }

    /**
     * 删除设备申请
     */
    @RequiresPermissions("fljg:facilitiesApplication:remove")
    @Log(title = "设备申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(facilitiesApplicationService.deleteFacilitiesApplicationByFids(fids));
    }
}
